//#ifdef HUNLIST_DEBUG
//#include "hunBase.h"
#include "hunList_test.h"
#include <stdio.h>
#include <stdlib.h>

//#define HUN_DEBUG_ON
#define PrintHeader()  hunR("Test %s %d\n", __func__, __LINE__)
// ----------------------------------------------------------------------------
hunBool hunListTestFront()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)7);
    hunList *item = hunList_Front(list);
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------
hunBool hunListTestBack()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)7);
    hunList *item = hunList_Back(list);
    hunList_Reset(list);
}

// ----------------------------------------------------------------------------
hunBool hunListTestPopFront()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)7);
    hunList *item = hunList_PopFront(list);
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------
hunBool hunListTestPopBack()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)7);
    hunList *item = hunList_PopBack(list);
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------

hunBool hunListTestPushFront()
{
    PrintHeader();
    hunList *list = NULL;
    int i;
    for(i=0;i<10;++i)
        list = hunList_PushFront(list, (void *)(100+i));
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------
hunBool hunListTestPushBack()
{
    PrintHeader();
    hunList *list = NULL;
    int i;
    for(i=0;i<10;++i)
        list = hunList_PushBack(list, (void *)(100-i));
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------
hunBool hunListTestFind()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    hunList *tmp;
    tmp = list;
    hunG("tmp = 0x%08X\n", tmp);
    list = hunList_PushBack(list, (void *)7);
    int item = hunList_Find(list,(void *)6);
    if(item == 1)
    {
        hunList *my_item = hunList_At(list, item);
        hunR("found! data=%d\n", my_item->data);
    }
    else
    {
        hunR("not found!\n");
    }
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------
hunBool hunListTestFindAll()
{
    PrintHeader();
    hunList *list = NULL;
    list = hunList_PushBack(list, (void *)5);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)7);
    list = hunList_PushBack(list, (void *)7);
    list = hunList_PushBack(list, (void *)6);
    list = hunList_PushBack(list, (void *)1);
    hunList *foundlist = hunList_FindAll(list,(void *)6);
    int size = hunList_Size(foundlist);
    hunB("size = %d\n", size);
    int i;
    for(i=0;i<size;++i)
    {
        hunList *tmpItem = hunList_At(foundlist, i);
        hunB("idx=%d\n", tmpItem->data);
    }
    hunList_Reset(foundlist);
    hunList_Reset(list);
}
// ----------------------------------------------------------------------------

hunBool hunListTestSize()
{
    PrintHeader();
}
// ----------------------------------------------------------------------------

hunBool hunListTestAll()
{

    hunListTestFront();
    hunListTestBack();

    hunListTestPopFront();
    hunListTestPopBack();

    hunListTestPushFront();
    hunListTestPushBack();

    hunListTestSize();

    hunListTestFind();
    hunListTestFindAll();

}
// ----------------------------------------------------------------------------

//#endif
